package com.leetcode.LC;

public class LC1455 {
    public int isPrefixOfWord(String sentence, String searchWord) {
        //长度不够就跳过，够就截取前缀判断，符合返回位置
        String[] s = sentence.split(" ");
        for (int i = 0; i < s.length; i++) {
            if (s[i].length() < searchWord.length()) {
                continue;
            } else {
                if (s[i].substring(0, searchWord.length()).equals(searchWord)) {
                    return i + 1;
                }
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(new LC1455().isPrefixOfWord("this problem is an easy problem", "pro"));
    }
}
